import mongoose from 'mongoose';

const BuySchema = new mongoose.Schema(
  {
    goodid: { type: mongoose.Schema.Types.ObjectId, ref: 'Good' },
    userid: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
    amount: Number,
    chapter: Number, // 购买的章节数
    des: String, // 订单描述信息
    create_time: Date
  },
  { versionKey: false }
);

BuySchema.index({ goodid: 1, userid: 1 });

const Buy = mongoose.model('Buy', BuySchema);

export { Buy };
